#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int num=0,fh=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')fh=-fh;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        num=num*10+c-'0';
        c=getchar();
    }
    return num*fh;
}       
int n,m,L,v;
int ans1=0,ans2=0;
const int N=1e5+2;
int a[N],ans[N];
int cnt=0;
int pos,ac,nv;
int wz[N];
int pp;
void add(int l,int r)
{
    a[l]++;;
    a[r+1]--;
}
struct node
{
    int l,r;
}edge[N];
struct node2
{
    int l,r,ls;
}e[N];
double aa,vv,aimv,x2;
int pg;
void init()
{
    cnt=0;
    for(int i=0;i<=N;i++)
    {
        wz[i]=0,a[i]=0,ans[i]=0;
    }
    ans1=0,ans2=0;
}
int cmp(node2 x1,node2 x2)
{
    return x1.r<x2.r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T=read();
    while(T--)
    {   
        n=read(),m=read(),L=read(),v=read();
        init();
        for(int i=1;i<=n;i++)
        {
            pos=read(),nv=read(),ac=read();
            if(ac==0)
            {
                if(nv>v)edge[++cnt]={pos,L};
            }
            else
            {
                if(ac<0)
                {
                    if(nv>v)
                    {
                        aa=ac*1.00;
                        vv=nv*1.00;
                        aimv=v*1.00;
                        x2=(aimv*aimv-vv*vv)/(2.0*aa)-0.0001;
                        int r=floor(x2);
                        edge[++cnt]={pos,pos+r};
                    }
                }
                else 
                {
                    
                    if(nv>v)
                    {
                        edge[++cnt]={pos,L};
                    }
                    else
                    {
                        aa=ac*1.00;
                        vv=nv*1.00;
                        aimv=v*1.00;
                        x2=(aimv*aimv-vv*vv)/(2.0*aa)+0.0001;
                        int r=ceil(x2);
                        edge[++cnt]={pos+r,L};
                    }
                }
            }
        }
        for(int i=1;i<=m;i++)
        {
            cin>>pos;
            wz[i]=pos;
        }
        
        wz[m+1]=1e9;
        sort(wz+1,wz+m+2);
        int nowg=0;
      
    
        for(int i=1;i<=cnt;i++)
        { 
            pp=lower_bound(wz+1,wz+m+1,edge[i].l)-wz;
            pg=upper_bound(wz+1,wz+m+1,edge[i].r)-wz;
            pg--;
            if(wz[pp]<=edge[i].r)
            {
                ans1++;
                e[ans1]={edge[i].l,edge[i].r,wz[pg]};
            }
        }
        sort(e+1,e+ans1+1,cmp);
        for(int i=1;i<=ans1;i++)
        {
            if(nowg>=e[i].l)ans2++;
            else
            {
                nowg=e[i].ls;
            }
        }
        cout<<ans1<<" "<<ans2+(m-ans1)<<"\n";
    }
    return 0;
}